package com.goblin.model.media.service;

import com.goblin.common.response.PageHelper;
import com.goblin.common.response.Paged;
import com.goblin.model.media.po.Chat;
import com.goblin.model.media.po.Message;
import com.goblin.model.media.repository.ChatRepository;
import com.goblin.model.media.repository.MessageRepository;
import com.goblin.model.uaa.po.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageRepository messageRepository;

    @Autowired
    private ChatRepository chatRepository;

    private static final Logger logger = LoggerFactory
            .getLogger(MessageServiceImpl.class);

    @Override
    public Paged<Chat> pagedChat(Integer userId, PageHelper pageable) {
        return this.chatRepository.paged(userId, pageable);
    }

    @Override
    public List<Chat> findChatByCustomA(User user) {
        List<Chat> list = this.chatRepository.findChatsByCustomA(user);
        return list;
    }

    @Override
    public Paged<Message> paged(Integer chatId, PageHelper pageable) {
        return this.messageRepository.paged(chatId, pageable);
    }
}
